package net.studio.simpletetris;

import java.io.IOException;
import java.io.InputStream;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class AboutActivity extends BaseActivity implements OnClickListener{
	
	private TextView txtAbout;
	private Button btnClose;
	private Button btnShareTo;

	@Override
	protected int getContentView() {
		return R.layout.activity_about;
	}
	
	@Override
	protected void doInitFindView() {
		super.doInitFindView();
		
    	txtAbout = (TextView) findViewById(R.id.textViewAbout);
    	btnClose = (Button) findViewById(R.id.btnClose);
    	btnClose.setOnClickListener(this);
    	btnShareTo = (Button) findViewById(R.id.btnShareTo);
    	btnShareTo.setOnClickListener(this);
    }
    
	@Override
	protected void doInitData() {
		super.doInitData();
		
    	InputStream is = getResources().openRawResource(R.raw.readme);
    	byte[] bytes;
		try {
			bytes = new byte[is.available()];
	        is.read(bytes);
	    	txtAbout.setText(new String(bytes, "UTF-8"));
		} catch (IOException e) {
			e.printStackTrace();
		}
    }

	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.btnClose:
			finish();
			break;
		case R.id.btnShareTo:
			MainActivity.doShareTo(this);
			break;
		}
	}

}
